<?php if (!defined('NOVA_RUN')) die('You can\'t access this file directly!');

/*
-------------------------------------------------------
*
*   NovaBoard 2
*   Copyright © 2011 NovaBoard team
*
*--------------------------------------------------------
*
*   Official site: www.novaboard.net
*   Contact e-mail: support@novaboard.net
*
*   GNU General Public License, version 2:
*   http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*
---------------------------------------------------------
*/

class Index_Action extends Action
{
	// current action name
	var $action = 'index';

	// avaliable methods
	var $methods = array('view');

	// default method
	var $default = 'view';

	public function view()
	{
		$tpl = tpl::instance();

		// Get categories with 3 sub-category level limit
		$catModel = new Category_Model();
		$gId = $this->curUser->info['group_id'];

		// Why doesn't we use one big query instead of many lesser ones? Because every query is cached anyway, and little queries are cached much easier, than bigger ones.
		
		$cats = $catModel->getFullCatTree(0, $this->curUser->info['group_id']);
		$tpl->assign('cats', $cats);
		
		// get users online
		$uOnline = $this->UserModel->getUsersOnline();
		$tpl->assign('users_online', $uOnline);
		$tpl->assign('uOnline', sizeof($uOnline));

		// get guests online
		$tpl->assign('gOnline', $this->UserModel->getGuestsOnline());

		// show template
		$tpl->show('index');
	}
}